package com.coco.goods.controller;

import com.coco.common.result.ResultData;
import com.coco.goods.pojo.TbEvaluate;

import com.coco.goods.service.EvaluateService;
import com.coco.goods.vo.Evaluate;
import com.coco.goods.vo.EvaluateSearchVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: coco
 * @author: Mr.Lin
 * @create: 2021-07-15 19:06
 **/
@Api
@RestController
@RequestMapping("/evaluate")
public class EvaluateController {

    @Autowired
    private EvaluateService evaluateService;


    /**
     * 回复评论
     *
     * @param id
     * @param evaluateSearchVo
     * @author lin
     */
    @PostMapping("/addReplyById/{id}")
    public void addReplyById(@PathVariable String id,
                             @RequestBody EvaluateSearchVo evaluateSearchVo) {
        evaluateService.addReplyById(id, evaluateSearchVo.getReplyContent());
    }

    /**
     *添加评论
     *
     * @Author: 张dy
     * @Date: 2021/8/5
     * @Param: [evaluate]
     */
    @RequestMapping("/addEvaluate")
    public void addEvaluate(@RequestBody Evaluate evaluate) {
        evaluateService.addGoodsEvaluate(evaluate);
    }


    /**
     * @Author 张dy
     * @Date 2021/7/15
     * @Param: [evaluate]
     * @return: com.coco.common.result.ResultData
     * @Description:查询评论 + 模糊 + 分页
     */
    @PostMapping("/search")
    public ResultData search(@RequestBody EvaluateSearchVo evaluate) {
        return evaluateService.search(evaluate);
    }

    /**
     * 删除评论
     *
     * @param id
     * @author: Mr.Lin
     */
    @DeleteMapping("/deleteEvaluateById/{id}")
    public void deleteEvaluateById(@PathVariable String id) {
        evaluateService.deleteEvaluateById(id);
    }




}
